/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package pe.edu.pucp.dp1.lectura.servidor;

import java.rmi.*;
import java.rmi.registry.*;
import java.rmi.server.*;
import java.util.ArrayList;
import Shared.ServLect;
import pe.edu.pucp.dp1.lectura.controlador.GestorCar;
import Shared.ListObjCarZona;
/**
 *
 * @author ed
 */
public class ServLectImpl extends UnicastRemoteObject implements ServLect {

    ServLectImpl() throws java.rmi.RemoteException {
        super();
    }

    public static GestorCar gestorCar = GestorCar.getInstance();
    
    public void iniciaLectura(){
        gestorCar.iniLectura();
    };

    public double getVelocidadPromedio()
    {
        return gestorCar.velocidadPromedio();
    }
    
    public ListObjCarZona getlistCarrosPorZona(int x, int y)
    {
        return gestorCar.listCarrosPorZona(x, y);
    }
    
    public ArrayList<ListObjCarZona> getlistCarrosTotal(){
        return gestorCar.listCarrosTotal();
    }

    
    public static void main(String args[]) {

        //System.setProperty("java.security.policy", "D:\\javafiles\\javapolicy\\java.policy");
        System.setProperty("java.security.policy", "/home/ed/Documentos/DP1/fuentes/javapolicy/java.policy");
        System.setProperty("java.rmi.server.hostname", "192.168.43.159"); //si es con otras compus
           
        try {
            ServLectImpl servLect;
//            LocateRegistry.createRegistry(1099);
//            String cmd = "rmiregistry";
//            Runtime.getRuntime().exec(cmd);
//            
            servLect = new ServLectImpl();
            Naming.rebind("//192.168.43.159:1099/ServLect", servLect);
            System.out.println("El servidor de lectura esta listo\n");            
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
